<!doctype html>
<html class="no-js">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>商之联运营商后台管理系统</title>
  <meta name="description" content="这是一个 table 页面">
  <meta name="keywords" content="table">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <link rel="icon" type="image/png" href="{:C('SUPPLIER_ADMIN_IMAGE')}favicon.png"> <link rel="apple-touch-icon-precomposed" href="{:C('SUPPLIER_ADMIN_IMAGE')}app-icon72x72@2x.png">
  <meta name="apple-mobile-web-app-title" content="Amaze UI" />
  <link rel="stylesheet" href="{:C('SUPPLIER_ADMIN_CSS')}amazeui.min.css"/>
  <link rel="stylesheet" href="{:C('ADMIN_CSS')}admin.css">
</head>
<body>
 <style type="text/css">
 .tabbox td{text-align: center;}
 .am-btn-toolbar .am-btn-group, .am-btn-toolbar .am-input-group{
  float: none;
 }
</style> 
<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
  以获得更好的体验！</p>
<![endif]-->
<!-- header start-->

<include file="Public:header"/>

<!-- header end-->

<div class="am-cf admin-main">
 <!-- sidebar start -->
   <include file="Public:menu"/>
  <!-- sidebar end -->
  
  <!-- content start -->
  <div class="admin-content">

    <div class="am-cf am-padding">
      <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">设备管理</strong> / <small>设备列表</small></div>
    </div>
    
      <!-- 搜索条件start -->
  <form >
    <div class="am-g ">
      <div class="am-u-sm-12 am-u-md-4 search">
        <p><label>查询内容：</label>&nbsp;&nbsp;&nbsp;<input type="text" name="devicecode" /> </p>
        <p><label>设备类型：&nbsp;&nbsp;</label>
        <select name="type">

              <option value="99"> 请选择</option>
              <foreach name="type" item='value' key="key">
                   <option value="{$key}"> {$value}</option>
              </foreach>
          
        </select>
        </p>
      </div>
      
      <div class="am-u-sm-12 am-u-md-4 search">
        <p><label>企业名称：</label>&nbsp;&nbsp;&nbsp;<input type="text" name="companyname" /> </p>
        <p><label>分配类型：&nbsp;&nbsp;</label>
        <select name="isfen">
              <option value="99"> 请选择</option>
              <option value="1">已分配</option>
              <option value="2">未分配</option>
        </select>
        </p>
      </div>

      <div class="am-u-sm-12 am-u-md-4 search">
      
      <p>  开始时间： <input class="laydate-icon" id="start" style="width:200px; margin-right:10px;"  /> </p>
      <p>  结束时间： <input class="laydate-icon" id="end" style="width:200px;"/></p>
    
      
      </div>

    </div>
    
    <div class="am-g search"> 
      <P>
      <button type="reset"><span class="am-icon-repeat"></span>重置</button>
      <button id="search"><span class="am-icon-search"></span>搜索</button> 
      </P>
    </div>
  <!-- 搜索条件end -->
</form>



    <div class="am-g">
      <div class="am-u-sm-12">
        <form class="am-form">
          <table class="am-table am-table-striped am-table-hover table-main devicetable">
            <thead>
              <tr>
                <th class="table-id">序号</th>
                <th class="table-title">设备标识号</th>
                <th class="table-title">创建时间</th>
                <th class="table-title">是否分配</th>
                <th class="table-title">设备类型</th>
                <th class="table-title">经销商公司</th>
                
                <th class="table-set">操作</th>
              </tr>
          </thead>
          <tbody>
            <foreach name="devices" item='device'>
            <tr class="tabbox">
              <td>{$device['deviceid']}</td>
              <td>{$device['devicecode']}</td>
              <td>{$device['createtime']}</td>
              <td>{$device['isfen']}</td>
              <td>{$device['devicetype']}</td>
              <td>{$device['companyname']}</td>
              
              <td>
                <div class="am-btn-toolbar">
                  <div class="am-btn-group am-btn-group-xs">
                    <button class="am-btn am-btn-default am-btn-xs am-text-secondary">
                   <span class="am-icon-pencil-square-o">  <a href="{:U('Equipmente/edit',array('id'=>$device['deviceid']))}"> 编辑</a></span>
                 </button>

                   
      
                  
                     
                   </if>

                     </button> 
                  </div>
                </div>
              </td>
            </tr>
            </foreach>
          </tbody>
        </table>
         
      <div class="am-fr page">
      <ul class="am-pagination" >
        <li>共<label class="count"> {$pagearr['count']}</label> 条记录</li>
        <li>当前第 <label class="currentpage"> {$pagearr['page']} </label> 页</li>
       <!-- <li><label>每页&nbsp;</label><input type="text" size="2" id="pagesize" value="15" onkeypress="return listTable.changePageSize(event)"></li> -->
        <li><a href="javascript:pageajax('firpage')" class="firpage" value="1" >第一页</a></li>
        <li><a href="javascript:pageajax('prepage')" class="prepage" value="{$pagearr['page']-1}">上一页</a></li>
        <li><a href="javascript:pageajax('nexpage')" class="nexpage" value="{$pagearr['page']+1}">下一页</a></li>
        <li><a href="javascript:pageajax('laspage')" class="laspage" value="{$pagearr['totalpage']}">最末页</a></li>
       <!-- <li><input type="text" size="2" id="pageSize"class="am-input-group-sm" value="15"/ >&nbsp; <button class="am-btn-default am-btn-primary am-fr">GO</button> </li>-->
      </ul>
  </div>
</div>
        </form>
      </div>

    </div>
  </div>
  <!-- content end -->
</div>


<script src="{:C('ADMIN_JS')}jquery.min.js"></script>
<include file="Public:footer"/>

<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}polyfill/rem.min.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}polyfill/respond.min.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}amazeui.legacy.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="{:C('SUPPLIER_ADMIN_JS')}amazeui.min.js"></script>
<!--<![endif]-->
<script src="{:C('SUPPLIER_ADMIN_JS')}app.js"></script>
<script src="{:C('ADMIN_JS')}laydate/laydate.js"></script>
<script type="text/javascript">
  var ajaxsearch=function(page)
  {
    //获取搜索条件
    var page = arguments[0]?arguments[0] : 1;
    var $companyname=$("input[name='companyname']").val();
    var $devicecode=$("input[name='devicecode']").val();
    var $starttime=$("#start").val();
    var $endtime=$("#end").val();    //$("select option:selected").val();
    var $isfen=$("select[name='isfen'] option:selected").val();
    var $type=$("select[name='type'] option:selected").val();
    $.ajax(
    {
      type:'POST',
      url:"{:U('Equipmente/searchDivece')}",
      data:{'starttime':$starttime,'type':$type,"isfen":$isfen,"endtime":$endtime,"companyname":$companyname,"devicecode":$devicecode,"page":page},
      dateType:'JSON',
      success:function(result)
      { 
          
          var result=jQuery.parseJSON(result);
          var $page=result.pagearr; //底部分页
          var $devices=result.devices;//设备
          var $tbody=$('<tbody></tbody>');
          var $string='';
        if (result.status)
        {
          
          $.each($devices,function(key,device){
            $string+="<tr>";
            $string+="<td>"+device.deviceid +"</td>";
            $string+="<td>"+device.devicecode+"</td>";
            $string+="<td>"+device.createtime+"</td>";
            $string+="<td>"+device.isfen +"</td>";
            $string+="<td>"+device.devicetype+"</td>";
            $string+="<td>"+device.companyname +"</td>";
            $string+="<td><span class='am-icon-pencil-square-o'></span><a href=__URL__/edit/id/"+device.deviceid+">编辑</td>";
            $string+="</tr>"; 
          });
          $tbody.append($string);
          $($tbody).replaceAll(".devicetable tbody");

          //替换分页
          $(".count").html($page.count);
          $(".currentpage").html($page.page);
          $("#pagesize").val($page.pagesize);
          $('.prepage').attr('value',$page.prevpage);
          $('.nexpage').attr('value', $page.nextpage);
          $('.laspage').attr('value',$page.pagetotal);
        }else
        {
           $tbody.append(result.message);
           $($tbody).replaceAll('.devicetable tbody');
        }
      }

    });
  }

  $('#search').click(function(){
      ajaxsearch();
      event.preventDefault();
    

  });
  //翻页事件
  function pageajax(name){
     var pagevalue=$('.'+name).attr('value');
     ajaxsearch(pagevalue);
    return false;
  }
  //日期插件

var start = {
    elem: '#start',
    format: 'YYYY-MM-DD hh:mm:ss',
    min: '1999-06-16 23:59:59', //设定最小日期为当前日期
    max: '2099-06-16 23:59:59', //最大日期
    istime: true,
    istoday: false,
    choose: function(datas){
         end.min = datas; //开始日选好后，重置结束日的最小日期
         end.start = datas //将结束日的初始值设定为开始日
    }
};
var end = {
    elem: '#end',
    format: 'YYYY-MM-DD hh:mm:ss',
    min: '1999-06-16 23:59:59',
    max: '2099-06-16 23:59:59',
    istime: true,
    istoday: false,
    choose: function(datas){
        start.max = datas; //结束日选好后，重置开始日的最大日期
    }
};
laydate(start);
laydate(end);
        
</script>
</body>